---
title: LangDB
description: Integrate Agno with LangDB to trace agent execution, tool calls, and gain comprehensive observability into your agent's performance.
---

## Integrating Agno with LangDB

[LangDB](https://langdb.ai/) provides an AI Gateway platform for comprehensive observability and tracing of AI agents and LLM interactions. By integrating Agno with LangDB, you can gain full visibility into your agent's operations, including agent runs, tool calls, team interactions, and performance metrics.

For detailed integration instructions, see the [LangDB Agno documentation](https://docs.langdb.ai/getting-started/working-with-agent-frameworks/working-with-agno).

<Frame caption="LangDB Finance Team Trace">
  <img
    src="/images/langdb-finance-trace.png"
    style={{ borderRadius: '10px', width: '100%', maxWidth: '800px' }}
    alt="langdb-agno finance team observability"
  />
</Frame>

## Prerequisites

1. **Install Dependencies**

   Ensure you have the necessary packages installed:

   ```bash
   pip install agno 'pylangdb[agno]'
   ```

2. **Setup LangDB Account**

   - Sign up for an account at [LangDB](https://app.langdb.ai/signup)
   - Create a new project in the LangDB dashboard
   - Obtain your API key and Project ID from the project settings

3. **Set Environment Variables**

   Configure your environment with the LangDB credentials:

   ```bash
   export LANGDB_API_KEY="<your_langdb_api_key>"
   export LANGDB_PROJECT_ID="<your_langdb_project_id>"
   ```

## Sending Traces to LangDB

### Example: Basic Agent Setup

This example demonstrates how to instrument your Agno agent with LangDB tracing.

```python
from pylangdb.agno import init

# Initialize LangDB tracing - must be called before creating agents
init()

from agno.agent import Agent
from agno.models.langdb import LangDB
from agno.tools.duckduckgo import DuckDuckGoTools

# Create agent with LangDB model (uses environment variables automatically)
agent = Agent(
    name="Web Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[DuckDuckGoTools()],
    instructions="Answer questions using web search and provide comprehensive information"
)

# Use the agent
response = agent.run("What are the latest developments in AI agents?")
print(response)
```

### Example: Multi-Agent Team Coordination

For more complex workflows, you can use Agno's `Team` class with LangDB tracing:

```python
from pylangdb.agno import init
init()

from agno.agent import Agent
from agno.team import Team
from agno.models.langdb import LangDB
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

# Research Agent
web_agent = Agent(
    name="Market Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[DuckDuckGoTools()],
    instructions="Research current market conditions and news"
)

# Financial Analysis Agent
finance_agent = Agent(
    name="Financial Analyst",
    model=LangDB(id="xai/grok-4"),
    tools=[YFinanceTools(stock_price=True, company_info=True)],
    instructions="Perform quantitative financial analysis"
)

# Coordinated Team
reasoning_team = Team(
    name="Finance Reasoning Team",
    model=LangDB(id="xai/grok-4"),
    members=[web_agent, finance_agent],
    instructions=[
        "Collaborate to provide comprehensive financial insights",
        "Consider both fundamental analysis and market sentiment"
    ]
)

# Execute team workflow
reasoning_team.print_response("Analyze Apple (AAPL) investment potential")
```

## Sample Trace

View a complete example trace in the LangDB dashboard: [Finance Reasoning Team Trace](https://app.langdb.ai/sharing/threads/73c91c58-eab7-4c6b-afe1-5ab6324f1ada)

<Frame caption="LangDB Finance Team Thread">
  <img
    src="/images/langdb-finance-thread.png"
    style={{ borderRadius: '10px', width: '100%', maxWidth: '800px' }}
    alt="langdb-agno finance team observability"
  />
</Frame>

## Advanced Features

### LangDB Capabilities
- **Virtual Models**: Save, share, and reuse model configurations—combining prompts, parameters, tools, and routing logic into a single named unit for consistent behavior across apps
- **MCP Support**: Enhanced tool capabilities through Model Context Protocol servers
- **Multi-Provider**: Support for OpenAI, Anthropic, Google, xAI, and other providers

## Notes

- **Initialization Order**: Always call `init()` before creating any Agno agents or teams
- **Environment Variables**: With `LANGDB_API_KEY` and `LANGDB_PROJECT_ID` set, you can create models with just `LangDB(id="model_name")`

## Resources

- [LangDB Documentation](https://docs.langdb.ai/)
- [Building a Reasoning Finance Team Guide](https://docs.langdb.ai/guides/building-agents/building-a-reasoning-finance-team-with-agno)
- [LangDB GitHub Samples](https://github.com/langdb/langdb-samples/tree/main/examples/agno)
- [LangDB Dashboard](https://app.langdb.ai/)

By following these steps, you can effectively integrate Agno with LangDB, enabling comprehensive observability and monitoring of your AI agents.
